import { GuardInstaller } from "@/router";
import { NOT_FOUND_ROUTE_NAME } from "@/router/routes/404.route.ts";

/*
    404页面路由守卫
 */

const installer: GuardInstaller = {
    priority: -99,
    install: function (router) {
        // @ts-ignore
        router.beforeResolve((to, from, next) => {
            if (!to.name && to.matched.length === 0) {
                next({ name: NOT_FOUND_ROUTE_NAME });
            } else {
                next();
            }
        });
    }
}

export default installer;